<template>
  <div>
    <div v-for="link in fieldValue" :key="link">
      <a-icon type="file" class="mr-1"></a-icon>
      <a :href="link" target="_blank" rel="noopener noreferrer" v-text="fileName(link)"></a>
    </div>
  </div>
</template>

<script>
import URL from 'url'
export default {
  name: 'File',
  props: {
    fieldValue: {
      type: Array,
      required: false,
      default: () => {
        return [];
      }
    }
  },
  methods: {
    fileName(url) {
      let path = URL.parse(url).path;
      return path.substring(path.lastIndexOf('/') + 1, path.indexOf('?'));
    }
  }
}
</script>

<style scoped>

</style>